package org.jkuang.qstar.commons.jni;

import java.util.HashMap;
import java.util.Map;
import java.util.Random;
import java.util.UUID;



public class S2STest {

	static void test1()
	{
		S2SMap smap = new S2SMap(1);
		for (int i = 0; i < 1024*1024; i++) {
			smap.put("i:"+i, "i:"+i);
			
			if(!smap.get("i:"+i).equalsIgnoreCase("i:"+i)) {
				System.out.println("er----------------------ror"+i);
				System.exit(0);
			}
			
		}

	}
	
	static void test2()
	{
		S2SMap smap = new S2SMap(100);
		Map<String, String> map = new HashMap<>();
		Random random = new Random();
		int count =0 ;
		int maxsyze=1024*1024;
		while (true) {
			String key = random.nextInt(1024*1024*10)+"";
			String value = UUID.randomUUID().toString();
			int num = random.nextInt();
			if(num%2==0) {
				map.remove(key);
				smap.remove(key);
			}else {
				map.put(key, value);
				smap.put(key, value);
			}
			if(count++%(maxsyze)==maxsyze-1) {
				for (String key0:map.keySet()) {
					String value0 =map.get(key0);
		
					if(!value0.equalsIgnoreCase(smap.get(key0))) {
						System.out.println("size:"+map.size());
						System.out.println("key0:"+key0);
					    System.out.println("value0:"+value0);
					    System.out.println("value1:"+smap.get(key0));
						System.out.println("er----------------------ror");
						System.out.println("er----------------------ror");
						System.out.println("er----------------------ror");
						System.out.println("er----------------------ror");
						System.exit(0);
					}
				}
				System.out.println("add/del:"+count+" map size:"+map.size());
			}
	
		}
	}
	
	public static void main(String[] args) {
		// TODO Auto-generated method stub
	
       test2();

	}

}
